package com.sq.futuralwakeupwordsdk;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.BarUtils;

public class BaseActivity extends AppCompatActivity {
    private Toast toast;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        toast = new Toast(this);

        //Objects.requireNonNull(getSupportActionBar()).hide();
        BarUtils.setStatusBarVisibility(this, false);
    }

    public void back(View view) {
        finish();
    }

    @Override
    protected void onResume() {
        super.onResume();
        hideBars();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    public void hideBars() {
        //Objects.requireNonNull(getSupportActionBar()).hide();
        BarUtils.setStatusBarVisibility(this, false);
        BarUtils.setNavBarVisibility(this, false);
    }

    public void showBars() {
        BarUtils.setStatusBarVisibility(this, true);
        BarUtils.setNavBarVisibility(this, true);
    }

    public void showMyToast(@StringRes int resId, int duration){
        showMyToast(getString(resId), duration);
    }

    public void showMyToast(String msg, int duration) {
        View view= LayoutInflater.from(this).inflate(R.layout.my_toast_custom,null);
        TextView tv_msg = view.findViewById(R.id.content_tv);
        tv_msg.setText(msg);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.setDuration(duration);
        toast.setView(view);
        toast.show();
    }
}